import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import { resolve } from "path"
// ⾃动导⼊
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-vue-components/vite"
import { ElementPlusResolver } from "unplugin-vue-components/resolvers"
import ElementPlus from "unplugin-element-plus/vite"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(), // ⾃动导⼊
    AutoImport({
      imports: ["vue", "vue-router"], // 顺便⾃动导⼊ vue vue-router
      resolvers: [ElementPlusResolver()],
      eslintrc: { enabled: false }, // 改成true⽣成⼀次后禁⽤即可
      dts: "src/auto-import.d.ts" // ⽣成的全局变量放到此⽬录下
    }),
    Components({
      // 配置自动导入组件的⽬录
      dirs: ["src/components", "src/layout/components"],
      dts: "src/components.d.ts",
      resolvers: [ElementPlusResolver()] // ⽣成的组件的类型放到这⾥
    }),
    ElementPlus({})
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src")
    }
  }
})
